
$(function() {
  $.ajax({
    url: 'http://127.0.0.1:9090/api/getinlanddiscount',
    success: function(info) {
      console.log(info)
      var index = 0;
      render();
      function render() {
        var str = ''
        if(index < 20) {
          for(var i = 0 ; i < 4 ; i++) {
            console.log(index)
            str += template('tmp',info.result[index])
            index++;
            console.log(str);
            
          }
          $('.inlanddiscount').append(str)
          
        }
      }

      $(window).scroll(function(){
        var iHeight=$('.inlanddiscount').height();
        var iTop=$('.inlanddiscount').offset().top; //item距离页面顶部距离
        var wHeight=$(window).height();
        var wTop=$(window).scrollTop();
        //items 距离浏览器窗口底部距离
        var h=iHeight+iTop-wHeight-wTop;

        if( h <0 ) {
          render()
        }
        
      })


    }
  })

  
})